import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
//导入持久化依赖包
import VuexPersistence from 'vuex-persist'
//实例化持久化插件对象
const vuexLocal = new VuexPersistence({
    storage: window.sessionStorage,//存储介质,
    // key: "vuex",//存储到本地存储
})

export default new Vuex.Store({
  state: {
    token:"", // 管理后台token值
    users:{}, // 登录信息
    isLoading:false , // loading效果
    bread:[],   // 面包屑
  },
  mutations: {
     // 管理后台登陆成功后存储数据
     goLogin(state,obj){
      console.log(obj)
      state.token = obj.token;
      state.users = obj;
     },
     // 执行退出的操作
     logout(state){
      state.token = "",
      state.users = {}
     },
     // loading 效果
     setLoading(state,status){
        state.isLoading = status;
     },
     // 设置面包屑
     setBread(state,bread){
       state.bread = bread
     },
  },
  actions: {
  },
  modules: {
  },
  plugins: [vuexLocal.plugin]
})
